package cn.tedu.io;

import java.io.File;
import java.util.Arrays;
import java.util.Scanner;

public class Test2_DiGui2 {
    public static void main(String[] args) {
        System.out.println("请输入文件夹路径：");
        String path = new Scanner(System.in).nextLine();
        File dir = new File(path);
        deleteAll(dir);
    }
    public static void deleteAll(File file){
        File[] fs =  file.listFiles();
        System.out.println(Arrays.toString(fs));

        for (int i = 0; i <fs.length ; i++) {
            if (fs[i].isFile()){
                fs[i].delete();
            }else  if(fs[i].isDirectory()){
                deleteAll(fs[i]);
            }
        }
        file.delete();//删除空的文件夹
    }
}
